$(function(){

	// - Pencere boyutu ve konumunu güncelle
	winResize();


	// - datePicker Settings
	$( ".datetime" ).datepicker( {regional : "tr"} );


	// - Geri Butonu işlevi
	$('.geri').click(function(){
		history.back();
	});


	//Fancybox Tekli resim
	$(".galeri").fancybox({
		padding: 0,

		openEffect : 'elastic',
		openSpeed  : 250,

		closeEffect : 'elastic',
		closeSpeed  : 250,

		closeClick : true,
		autoHeight : true,

		helpers : {
			overlay : null
		}
	});
	
	
	
});
	
	$(window).resize(function(){
		winResize();
	});

	function toPost(URL, DATA)
	{
		var result = $.ajax({
			type:'post',
			url: URL,
			data:DATA,
			async:false
		}).responseText;
		return result;
	}


	function toGet(URL, DATA)
	{
		var result = $.ajax({
			type:'get',
			url: URL,
			data:DATA,
			async:false
		}).responseText;
		return result;
	}


	function getHeaderHeight(){
		var headerHeight = $('#header').outerHeight() + parseInt($("#header").css("margin-top")) + parseInt($("#header").css("margin-bottom"));
		return headerHeight;
	}
	
	function getFooterHeight(){
		var footerHeight = $('#footer').outerHeight() + parseInt($("#footer").css("margin-top")) + parseInt($("#footer").css("margin-bottom"));
		return footerHeight;
	}
	
	function getBgWrapHeight(){
		var bgwrapHeight = $('#bgwrap').outerHeight() + parseInt($("#bgwrap").css("margin-top")) + parseInt($("#bgwrap").css("margin-bottom"));
		return bgwrapHeight;
	}
	
	function getWindowHeight(){
		var windowHeight=$(window).innerHeight();
		return windowHeight;
	}
	
	function getContentHeight(){
		var contentHeight = $('#content').outerHeight() + parseInt($("#content").css("margin-top")) + parseInt($("#content").css("margin-bottom"));
		return contentHeight;
	}


	function winResize()
	{
		if((getHeaderHeight() + getFooterHeight() + getContentHeight()) < getWindowHeight()){
			$("#bgwrap").css("height",(getWindowHeight() - (getHeaderHeight() + getFooterHeight()))+"px");
		}
		
		if((getHeaderHeight() + getFooterHeight() + getContentHeight()) >= getWindowHeight()){
			$("#bgwrap").css("height",getBgWrapHeight()+"px");
		}
	}